package com.docMan.bean;

import com.docMan.dao.pojo.DocDisc;
import com.docMan.service.DocDiscService;
import com.docMan.utils.SpringContextUtils;

public class UpdateDiskRunnable implements Runnable{
	private DocDiscService docDiscService=(DocDiscService) SpringContextUtils.getObject("docDiscService");
	
	private DocDisc docDisc;
	private double large;
	private int docDiscId;
	private int fileCount;
	private int dirCount;
	public UpdateDiskRunnable(DocDisc docDisc) {
		super();
		this.docDisc = docDisc;
	}

	public UpdateDiskRunnable(int docDiscId,double large){
		this.large=large;
		this.docDiscId=docDiscId;
	}
	
	public UpdateDiskRunnable(int docDiscId, int fileCount) {
		super();
		this.docDiscId = docDiscId;
		this.fileCount = fileCount;
	}

	public UpdateDiskRunnable(int docDiscId, int dirCount,int fileCount) {
		super();
		this.docDiscId = docDiscId;
		this.dirCount = dirCount;
		this.fileCount=fileCount;
	}
	

	public UpdateDiskRunnable(int docDiscId,double large, int fileCount) {
		super();
		this.large = large;
		this.docDiscId = docDiscId;
		this.fileCount = fileCount;
	}

	public UpdateDiskRunnable( int docDiscId,double large, int fileCount,
			int dirCount) {
		super();
		this.large = large;
		this.docDiscId = docDiscId;
		this.fileCount = fileCount;
		this.dirCount = dirCount;
	}

	@Override
	public void run() {
//		docDiscService.update(docDisc);
		DocDisc docDisc=docDiscService.getById(docDiscId);
		docDisc.setLarge(large+docDisc.getLarge());
		docDisc.setFileCount(docDisc.getFileCount()+fileCount);
		docDisc.setDirectoryCount(dirCount+docDisc.getDirectoryCount());
		docDiscService.update(docDisc);
	}
}
